package com.pinda.controller;


import com.pinda.base.entity.PdGoodsType;
import com.pinda.feign.PdAreaControllerFeignClients;
import com.pinda.feign.PdOrderControllerFeignClients;
import com.pinda.oms.entity.PdOrder;
import com.pinda.oms.entity.vo.Order_OrderCargoVo;
import com.pinda.service.IPdAddressBookService;
import com.pinda.users.entity.PdAddressBook;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

/**
 * <p>
 * 地址簿 前端控制器
 * </p>
 *
 * @author lc
 * @since 2023-06-14
 */
@RestController
@RequestMapping("/pd-address-book")
public class PdAddressBookController {

    @Resource
    private IPdAddressBookService iPdAddressBookService;

    @Resource
    private PdOrderControllerFeignClients pdOrderControllerFeignClients;

    @Resource
    private PdAreaControllerFeignClients pdAreaControllerFeignClients;

    @GetMapping("getByUserId")
    public List<PdAddressBook> getByUserId(String id) throws Exception {

     return this.iPdAddressBookService.getByUserId(id);
    }

    @PostMapping("saveAddressBook")
    public boolean saveAddressBook(@RequestBody PdAddressBook pdAddressBook){

        return this.iPdAddressBookService.saveAddressBook(pdAddressBook);
    }

    @PostMapping("updateAddressBook")
    public boolean updateAddressBook(@RequestBody PdAddressBook pdAddressBook){

        return this.iPdAddressBookService.updateAddressBook(pdAddressBook);
    }

    @GetMapping("deleteAddressBook")
    public boolean deleteAddressBook(String id){
        return this.iPdAddressBookService.removeById(id);

    }

    @PostMapping("saveOrder")
    public boolean saveOrder(@RequestBody Order_OrderCargoVo orderOrderCargoVo) throws ParseException {

        return this.iPdAddressBookService.saveOrder(orderOrderCargoVo);
    }

    @PostMapping("queryOrder")
    public List<PdOrder> queryOrder(String memberId) {

        return this.pdOrderControllerFeignClients.queryOrder(memberId);
    }

    @GetMapping("queryByIdOrder")
    public PdOrder queryByIdOrder(String id) {

        return this.pdOrderControllerFeignClients.queryByIdOrder(id);
    }

    @GetMapping("getListPdGoodsType")
    public List<PdGoodsType> getListPdGoodsType(){
        return this.pdAreaControllerFeignClients.getListPdGoodsType();
    }

}
